package example.bookservlet;


import example.entity.Book;
import example.service.BookService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 根据条件模糊查询图书
 *
 * @author 张心怡
 * @date 2024/12/16
 */
@WebServlet("/searchBooksServlet")
public class SearchBooksServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String keyword = request.getParameter("keyword");
        List<Book> books = BookService.searchBooks(keyword);
        request.setAttribute("books", books);
        request.getRequestDispatcher("manageBooks.jsp").forward(request, response);
    }
}